package demo2;

import java.util.Scanner;

/**
 * @author Huangjin
 * @version 1.0
 * describe:
 * @date 2023/2/20 19:29
 */
public class CaltotalAvg {
    public static void main(String[] args) {
        double[] socres = fetchScores();
        System.out.println(calScoreAvg(socres));
        System.out.println(calTotal(socres));

    }
    public static double[] fetchScores(){
        double[] scores = new double[6];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 6; i++) {
            System.out.println("请输入第"+i+"位评委的分数：");
            scores[i]  = sc.nextDouble();
        }
        return scores;
    }
    public static double calTotal(double[] a){
        double total = 0.0;
        double max = 0;
        double min = 0;
        for (int i = 0; i < a.length; i++) {
            if (max<a[i]){
                max = a[i];
            }
            if (min>a[i]){
                min = a[i];
            }
            total+=a[i];
        }
        return  total-max-min;

    }
    public static double calScoreAvg(double[] scores){
        double totalScore = calTotal(scores);
        double avg = totalScore/(scores.length-2);
        return avg;
    }
}
